package view;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import javax.swing.ImageIcon;
import controller.Controller;

public class StatsDisplayPanel extends GamePanel {
	private static final long serialVersionUID = 1L;

	public StatsDisplayPanel(Stage parent, Controller controller,  int w, int h) {
		super(parent, controller, w, h);
	}

	protected void init() {
		setLayout(null);
		setBackground(Color.lightGray);
	}

	@Override
	public void paintComponent(Graphics g){
		super.paintComponent(g);
		String path = null;
		String data = null;
		if(mr.entitySelected() == true) {
			switch(mr.getSelectedEntityID()){
			case 1:
				path = "/resource/Player.png";
				String rcr = "RCR:" + Integer.toString(mr.getRCR());
				data = rcr;
				break;
			case 100:// Tipi
				path = "/resource/Inventory/Tipi.png";
				data = "Your basic Tipi";
				break;
			default:
				path = "/resource/Inventory.png";
				data = "N/A";
				break;
			}
		}
		else { // Enter if Tile
			String type = null;
			switch(mr.getTileType()){
			case 0:
				path = "/resource/Tiles/Bog.png";
				type = "Bog";
				break;
			case 1:
				path = "/resource/Tiles/Wood.png";
				type = "Wood";
				break;
			case 2:
				path = "/resource/Tiles/Stone.png";
				type = "Stone";
				break;
			case 3:
				path = "/resource/Tiles/Field.png";
				type = "Field";
				break;
			default:
				path = "/resource/Inventory.png";
				data = "N/A";
				break;
			}
			String x = Long.toString(mr.getX());
			String y = Long.toString(mr.getY());
			data = type + "(" + x + ", " + y + ")";
		}

		ImageIcon image = new ImageIcon(getClass().getResource(path));
		g.drawImage(image.getImage(), 5, 5, 100, 86, null);
		Font font = new Font("Times New Roman", Font.BOLD, 24);
		g.setFont(font);
		g.drawString(data, 5, this.getWidth()*1/2 + 25);
	}

	@Override
	protected void update() {
		repaint();
	}
}
